#! /bin/sh
#### Run GBmod with CWP PostScript Graphics
#### Create Figure 8 in the GBmod paper

if test "$PSPREVIEWER" = ""
then
echo "Environment variable PSPREVIEWER not set" ; exit 1
fi

# model number
model=4

####  find the right directory
datadir=../datadir/

####  aux files
modelfile=${datadir}model${model}.data
modelpsfile=${datadir}model${model}.eps
rayendsfile=${datadir}rayend.data
rayfile=${datadir}ray.data
raypsfile=${datadir}ray.eps
fresnelfile=${datadir}fresnel.data
fresnelpsfile=${datadir}fresnel.eps

nangle=1 nxz=201 fangle=22 langle=40 ffreq=50

####   generate modelfile and modelpsfile
#../Models/PSmodel${model}

####   shoot the rays 
triray <$modelfile >$rayendsfile \
        rayfile=$rayfile fresnelfile=$fresnelfile \
        nxz=$nxz xs=5 zs=1.2 ffreq=$ffreq krecord=2 \
        fangle=$fangle langle=$langle nangle=$nangle\
	refseq=2,-1  refseq=8,1 \
        refseq=9,1 refseq=10,1 

nangle=`cat outpar`

####   plot the rays 
psgraph <$rayfile >$raypsfile \
        nplot=$nangle n=$nxz hbox=3 wbox=6.0  \
        x1beg=0 x1end=10 x2beg=0 x2end=20 \
        style=seismic linegray=1 title="Fresnel volume ($ffreq Hz)"

####   plot the Fresnel-volumes
psgraph <$fresnelfile >$fresnelpsfile \
        nplot=`expr $nxz \* $nangle` n=2 hbox=3 wbox=6.0\
        x1beg=0 x1end=10 x2beg=0 x2end=20 \
        style=seismic linegray=1 

####    display rays, model, and Fresnel-volumes
$CWPROOT/bin/psmerge in=$modelpsfile in=$raypsfile in=$fresnelpsfile |
	$PSPREVIEWER &

exit 0
